<template>
	<view scroll-with-animation scroll-y style="height:100%;position: relative;background-color: #F8FBFB;padding-top: 20rpx;padding-bottom: 50rpx;">
		<view style="background-color: #FFFFFF;padding-left: 40rpx;padding-bottom: 20rpx;">
			<view style="border-bottom: 2rpx solid #E1E1E1;padding-top: 20rpx;padding-bottom: 20rpx;font-size: 30rpx;font-weight: bolder;">
				基础信息：
			</view>
			<view class="crad-row" style="display: flex;align-items: center;justify-content: space-between;">
				<view>就诊人：</view>
				<view style="margin-right: 40rpx;">{{usrPersonName}}</view>
			</view>
			<view class="crad-row" style="display: flex;align-items: center;justify-content: space-between;">
				<view>送检医生:</view>
				<view style="margin-right: 40rpx;">{{doctorName}}</view>
			</view>
			<view class="crad-row" style="display: flex;align-items: center;justify-content: space-between;">
				<view>检验编号：</view>
				<view style="margin-right: 40rpx;">{{testNo}}</view>
			</view>
			<view class="crad-row" style="display: flex;align-items: center;justify-content: space-between;">
				<view>报告时间：</view>
				<view style="margin-right: 40rpx;">{{resultDate}}</view>
			</view>
			<view class="crad-row" style="display: flex;align-items: center;justify-content: space-between;">
				<view>检验单来源：</view>
				<view v-if="labSource!=null&&labSource==0" style="margin-right: 40rpx;">门诊检验单</view>
				<view v-if="labSource!=null&&labSource==1" style="margin-right: 40rpx;">住院检验单</view>
			</view>
		</view>
		
		<view v-if="type==0" class="card-plane" style="margin-bottom: 20rpx;">
			<view style="border-bottom: 2rpx solid #E1E1E1;padding-top: 20rpx;padding-bottom: 20rpx;font-size: 30rpx;font-weight: bolder;">
				检查类别：{{item}}
			</view>
			<view class="crad-row" style="display: flex;align-items: center;">
				<view style="width: 25%;">项目名称</view>
				<view style="width: 25%;">结果</view>
				<view style="width: 25%;">异常</view>
				<view style="width: 25%;">参考值</view>
			</view>
			<view v-for="item in subList" class="crad-row" style="display: flex;align-items: center;">
				<view style="width: 25%;">{{item.subclassItemName}}</view>
				<view style="width: 25%;">{{item.subclassResult}}</view>
				<view style="width: 25%;">
					{{item.subclassAbnormal}}
					<!-- <image src='../../static/images/sjt.png' style="height: 40rpx;" mode="heightFix"></image> -->
				</view>
				<view style="width: 25%;">{{item.subclassReference}}</view>
			</view>
			
		</view>
		<view class="card-plane" v-if="type==1" v-for="item in imgUrl">
			<image :src="item" style="width: calc( 100% - 40rpx );" mode="widthFix"></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				wx: "https://app.mzmzb.com",
				userId:undefined,
				problemsList:[],
				id:null,
				usrPersonName:'',//就诊人
				doctorName:'',//就诊医生
				testNo:'',//检验编号
				labSource:null,//来源0：门诊检验单 1：住院检验单
				resultDate:'',//报告时间
				type:0,//类型 0:his拉取  1：手动上传图片
				imgUrl:[],//图片地址
				item:'',//类别
				subList:[],//小类列表
			};
		},
		onLoad(option) {
			console.log(option)
			//this.userId = option.userId
			//this.getRecipieList();
			this.id=option.id;
			this.type=option.type;
			if(option.type==1){
				this.imgUrl=option.imgUrl.split(",")
			}
			this.getMedicalSpecimensInfo();
		},
		methods: {
			formatDate(value) {
			  var date = new Date(value);
			  var y = date.getFullYear(),
			    m = date.getMonth() + 1,
			    d = date.getDate(),
			    h = date.getHours(),
			    i = date.getMinutes(),
			    s = date.getSeconds();
			  if (m < 10) { m = '0' + m; }
			  if (d < 10) { d = '0' + d; }
			  if (h < 10) { h = '0' + h; }
			  if (i < 10) { i = '0' + i; }
			  if (s < 10) { s = '0' + s; }
			  var t = y + '-' + m + '-' + d + ' ' + h + ':' + i + ':' + s;
			  return t;
			},
			getMedicalSpecimensInfo(){
				var that = this;
				let openid=uni.getStorageSync('openId')
				let usrUserId=uni.getStorageSync('usrUserId')
				that.func.$request('getMedicalSpecimensInfo.tz',{id:this.id},'GET').then(res=>{
					if (res.data.success) {
						console.log(res)
						//that.medicalSpecimensList = JSON.parse(JSON.stringify(res.data.result.list));
						//that.number=res.data.result.number
						that.usrPersonName=res.data.result.usrPersonName;
						that.doctorName=res.data.result.doctorName;
						that.testNo=res.data.result.testNo;
						that.labSource=res.data.result.labSource;
						that.resultDate=res.data.result.resultDate;
						if(that.type==0){
							that.item=res.data.result.item;
							that.subList=JSON.parse(JSON.stringify(res.data.result.subList));
						}
					} else {
						uni.showToast({
							title: '查询失败'
						})
					}
				})
			}
		}
	};
</script>

<style lang="less">
	.add-btn{
		margin: auto;
		height: 88rpx;
		line-height: 88rpx;
		width: 90%;
		background: linear-gradient(90deg, #23E0D3 0%, #00BAAD 100%);
		box-shadow: 0px 20rpx 25rpx 0px rgba(0, 186, 173, 0.4);
		border-radius: 44rpx;
		color: #FFFFFF;
		text-align: center;
	}
	.card-plane{
		background-color: #FFFFFF;
		padding-left: 40rpx;
		padding-bottom: 20rpx;
		margin-top: 20rpx;
	}
	.crad-row{
		margin-top: 20rpx;
	}
	.row-border{
		border-bottom: 2rpx solid #E1E1E1;
	}
</style>
